package com.heima.service.impl;

import com.heima.mapper.EmpMapper;
import com.heima.pojo.JobOption;
import com.heima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> maps = empMapper.countEmpJobData();
        //处理数据拿到jobList 和dataList
        System.out.println(maps+"==========================");
        maps.stream().forEach(System.out::println);


        List<Object> pos = maps.stream().map(o -> o.get("pos")).toList();
        List<Object> total = maps.stream().map(o -> o.get("total")).toList();
        return new JobOption(pos,total);
    }

    @Override
    public List<Map> getSexData() {
        List<Map> maps=empMapper.getSexData();
        return maps;
    }
}
